<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
</head>
<body>
<input type="text" placeholder="请输入添加图片的数量">
<input type="button" value="小猫" onclick="f(1)">
<input type="button" value="小狗" onclick="f(2)">
<script>
    let i = document.querySelector("input");
    function f(x){
        if (isNaN(i.value)){
            let h = document.createElement("h1");
            h.innerText="输入错误";
            document.body.append(h);
            return
        }
        let url = x==1?"c.png":"d.png";
        for (let j = 0; j < i.value*1; j++) {
            let img = document.createElement("img");
            img.src=url;
            document.body.append(img);
        }


    }
</script>
</body>
</html>